﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlexiCommerce.Components;

namespace FlexiCommerce
{
    public class CancellableItemEventArgs : ItemEventArgs
    {
        private bool cancel;
        private Action<PersistenceItem> finalAction;

        /// <summary>Creates a new instance of the CancellableItemEventArgs.</summary>
        /// <param name="item">The content item to reference with these arguements.</param>
        public CancellableItemEventArgs(PersistenceItem item, Action<PersistenceItem> finalAction)
            : base(item)
        {
            this.finalAction = finalAction;
        }

        /// <summary>Creates a new instance of the CancellableItemEventArgs.</summary>
        /// <param name="item">The content item to reference with these arguements.</param>
        public CancellableItemEventArgs(PersistenceItem item)
            : base(item)
        {
        }

        /// <summary>Gets or sets whether the event with this argument should be cancelled.</summary>
        public bool Cancel
        {
            get { return cancel; }
            set { cancel = value; }
        }

        /// <summary>The action to execute unless the event is cancelled. This action can be exchanged by observers to alter the default behaviour.</summary>
        public Action<PersistenceItem> FinalAction
        {
            get { return finalAction; }
            set { finalAction = value; }
        }
    }
}
